using System.Collections.Generic;

namespace FadeLang.Runtime
{
    public class Scope
    {
        public readonly Dictionary<string, dynamic> VariableObjects = new Dictionary<string, dynamic>();
        public Scope ParentScope { get; set; }

        public dynamic GetValue(string varName) {
            var current = this;
            while (current != null) {
                if (current.VariableObjects.ContainsKey(varName)) {
                    return current.VariableObjects[varName];
                }
                current = current.ParentScope;
            }
            return null;
        }
    }
}